import actionTypes from './actionTypes'

// 2.获取actiontype
const handleSeeting = () => {
    return {
        type: actionTypes.SETTING_THEME
    }
}
export const seetingHandle = (data) => {
    return dispatch => {
        dispatch(handleSeeting())
        loginRequest(userInfo)
            .then(resp => {
                if (resp.data.code === 200) {
                    const {
                        authToken,
                        ...userInfo
                    } = resp.data.data
                    if (userInfo.remember === true) {
                        window.localStorage.setItem('authToken', authToken)
                        window.localStorage.setItem('userInfo', JSON.stringify(userInfo))
                    } else {
                        window.sessionStorage.setItem('authToken', authToken)
                        window.sessionStorage.setItem('userInfo', JSON.stringify(userInfo))
                    }
                    dispatch(loginSuccess(resp.data.data))
                } else {
                    dispatch(loginFailed())
                }
            })
    }
}